#!/bin/bash

protocol_str="$1"
script_filename="${protocol_str#*=}"

#tmpfile_bash_md_snippet=$(mktemp)
#(echo -e '``` bash'; cat $script_filename; echo -n -e '\n```') > $tmpfile_bash_md_snippet

tmux new-session -d -s demo
tmux set default-command 'bash'

tmux send-keys "export PS1=''; clear; glow -s light $script_filename" C-m
#tmux select-pane -d
tmux split-window -h;                             # split the detached tmux session
#tmux send-keys "bash $script_filename" C-m                     # send 2nd command 'htop -t' to 2nd pane. I believe there's a `--target` option to target specific pane.
#tmux send-keys "echo $script_filename \; echo hi \;" C-m                     # send 2nd command 'htop -t' to 2nd pane. I believe there's a `--target` option to target specific pane.
tmux send-keys -t .1 "export PS1=''; clear; bash $script_filename" C-m
#tmux select-pane -d
tmux a
#tmux if-shell 'while [ "x$keypress" != "xq" ]; do keypress="$(cat -v)";  done' 'tmux kill-session'

#paste <(echo "\$cat $script_filename"; echo -e "\`\`\` bash\n$(< "$script_filename")" '\n```' |glow -n -) <( echo "\$bash $script_filename"; bash "$script_filename")

#read -p "等待退出..." -t 1000 
